<?php
class Unit_model extends CI_Model{
	
	function   __construct() {
        parent::__construct();
    }

	function insert($data){
	$data = array(
            'strnama_unit' => $this->input->post('strnama_unit'));
        $this->db->insert('unit', $data);
	}

   function delete($idunit){
       $this->db->where('intid_unit', $idunit);
       $this->db->delete('unit');
    }

    function select($idunit){
       $query = $this->db->query("select * from Unit where intid_unit= $idunit");
	   return $query->result();
    }

	function update($idunit){
            $data = array(
            'strnama_unit' => $this->input->post('strnama_unit'));
            $this->db->where('intid_unit', $idunit);
            $this->db->update('unit',$data);
    }
	
	 function insert_babymanager($unit_baru, $unit_awal){
	$data = array(
            'intid_unit' => $unit_awal,
            'intid_unitbaby' => $unit_baru
		);
	
        $this->db->insert('baby_manager', $data);
	}
	  function Cari_unit($limit,$offset,$strnama_unit)
	{
	    $q = $this->db->query("SELECT *  FROM unit
            WHERE strnama_unit LIKE '%$strnama_unit%' LIMIT $offset,$limit");
	    return $q;

           }

	function tot_hal($tabel,$field,$kata)
	{
	    $q = $this->db->query("select * from $tabel where $field like '%$kata%'");
	    return $q;
	}
}
?>
